#ifndef UpdateXmlParser_H
#define UpdateXmlParser_H

#include <QObject>
#include <QDir>
#include <QDomElement>
#include <QDomNode>
#include <QFile>
#include <QDebug>
#include <QIODevice>

#include "log.h"
#include "update/agreementmsg.h"

#define ROOTNAME "SLCD"

typedef struct{
    QString fileName;
    quint32 filelen;
    QString checkSum;
} FileDate;

typedef struct{
    QString version;
    QString updatePath;
    int updateFileCount;
    int removeFileCount;
    QStringList removeFileList;
    quint8 parsexmlState;                   //
    QList<FileDate> updateFileList;
} UpdateInfo;

class UpdateXmlParser : public QObject
{
    Q_OBJECT

    LOG4QT_DECLARE_QCLASS_LOGGER

public:
    explicit UpdateXmlParser(QObject *parent = 0);

    void setParsetFile(const QString& xmlProPath);

//    ProjectStruct parserUpdateInfoFile(const QString& xmlProPath) const;
    UpdateInfo parser(const QString& xmlProPath);

private:
    QString xmlPath;

private:

signals:
    //解析完成，err，错误情况；publishTime,发布情况；dbPath，数据数据；resourcePath，资源路径
    //err：-1,找不到路径；-2，xml文件格式错误；-3，rootName错误;-4,projectName错误
    void parserFinish(int err, const QString& proPath = 0, const QString& publishTime = 0, const QString& dbPath = 0, const QString& resourcePath = 0);



};

#endif // UpdateXmlParser_H
